<style>
    .inventoryProductDetailForm-title {
        width: 100%;
        margin-left: 20px;
    }

    .inventoryProductDetailForm-title .title, .title {
        display: inline-block;
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 19px;
        position: relative;
        padding: 6px 0 19px 0;
    }

    .inventoryProductDetailForm-title .title:after, .title:after {
        content: '';
        display: block;
        position: absolute;
        left: 0;
        bottom: 0;
        width: calc(100% + 6px);
        height: 3px;
        background: #0A8B0A;
    }

</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <form class="layui-form">
                <div class="layui-form lay-header">

                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">

                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">物料名称：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="skuName" class="layui-input" type="text"
                                                   placeholder="物料名称"/>
                                        </div>
                                    </div>


                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">库位编码：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="shelfSpaceCode" class="layui-input" type="text"
                                                   placeholder="请输入库位编码"/>
                                        </div>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">仓库：</label>
                                        <div class="layui-input-inline mr0">
                                            <select id="warehouseId" name="warehouseId" lay-filter="warehouseId" lay-search
                                                    lay-verify=""></select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">库区：</label>
                                        <div class="layui-input-inline mr0">
                                            <select id="warehouseAreaId" name="warehouseAreaId" lay-filter="warehouseAreaId"
                                                    lay-search lay-verify=""></select>
                                        </div>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">货架：</label>
                                        <div class="layui-input-inline mr0">
                                            <select id="shelfId" name="shelfId" lay-search lay-verify="" ></select>
                                        </div>
                                    </div>




                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">物料编码：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="skuCode" class="layui-input" type="text" autocomplete="off"
                                                   placeholder="物料编码"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">料箱编码：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="palletBoxCode" class="layui-input" type="text" autocomplete="off"
                                                   placeholder="请输入料箱编码"/>
                                        </div>
                                    </div>




                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn icon-btn color-green"
                                                id="productInventorySearch" lay-filter="productInventorySearch"
                                                lay-submit>查询
                                        </button>
                                        <button type="reset" class="layui-btn icon-btn color-white" lay-filter="resets"
                                                lay-submit>重置
                                        </button>


                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
            <table class="layui-table" id="palletBoxSkuItermTable" lay-filter="palletBoxSkuItermTable"></table>
        </div>
    </div>
</div>



<!-- 表格操作列 -->
<script type="text/html" id="productInventoryTableBar">
  <!--  <a class="layui-btn layui-btn layui-btn-xs" lay-event="inventoryDistribution">库存分布</a>-->
</script>


<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laydate = layui.laydate;
        var unitName;

        //仓库列表
        admin.initDataSelect("enterprisecab/warehouse/admin/warehouse/list", {limit: 9999}, "warehouseId", null, "仓库", null, null);
        //仓库选择事件
        form.on('select(warehouseId)', function (data) {
            $("#warehouseAreaId").empty();
            //仓库库区列表
            admin.initDataSelect("enterprisecab/warehouse/admin/warehouseArea/list", {
                limit: 9999,
                warehouseId: data.value
            }, "warehouseAreaId", null, "库区", null, null);
        });
        //仓库库区选择事件
        form.on('select(warehouseAreaId)', function (data) {
            $("#shelfId").empty();
            //库区货架列表
            admin.initDataSelect("enterprisecab/warehouse/admin/warehouseShelf/list", {
                limit: 9999,
                warehouseAreaId: data.value
            }, "shelfId", null, "库区货架", null, null);
        });


        // 渲染表格
        var insTb = table.render({
            elem: '#palletBoxSkuItermTable',
            url: config.base + 'enterprise/palletBoxSkuIterm/admin/palletBoxSkuIterm/list',
            page: true,
            limit: 10,
            limits: [5, 10, 20, 30, 40, 50, 60, 70, 80],
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', title: "序号", width: 60}
                , {field: 'skuName', align: 'center', title: '物料名称'}
                , {field: 'skuCode', align: 'center', title: '物料编码'}
                , {field: 'skuSpec', align: 'center', title: '物料规格'}
                , {field: 'num', align: 'center', title: '数量'}
                , {field: 'warehouseName', align: 'center', title: '仓库'}
                , {field: 'warehouseAreaName', align: 'center', title: '库区'}
                , {field: 'shelfName', align: 'center', title: '货架'}
                , {field: 'shelfSpaceName', align: 'center', title: '库位'}
                , {field: 'shelfSpaceCode', align: 'center', title: '库位编码'}
                , {field: 'palletBoxCode', align: 'center', title: '料箱编号'}
                , {align: 'center', toolbar: '#productInventoryTableBar', title: '操作', width: 200}
            ]],
            done: function (res, curr, count) {
            }
        });
        form.render('select');

        // 工具条点击事件
        table.on('tool(palletBoxSkuItermTable)', function (obj) {
            var data = obj.data;

        });

        // 搜索
        form.on('submit(productInventorySearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
            return false;
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            $(".lay-query-box").find('select').val("");
            $(".lay-query-box").find('input').val("");
            xmSelect.get('#selectProductType')[0].setValue([])
            var field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });

    });
</script>